import logging
from logging.handlers import RotatingFileHandler

def setup_logger(app):
    handler = RotatingFileHandler(
        'app.log',
        maxBytes=1024 * 1024,
        backupCount=3
    )
    formatter = logging.Formatter(
        '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    handler.setFormatter(formatter)
    app.logger.addHandler(handler)
    app.logger.setLevel(logging.INFO)
